﻿using Microsoft.Graphics.Canvas;
using Microsoft.Graphics.Canvas.Effects;

using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using Windows.Graphics.Imaging;

namespace 纸片人.win2dEffectControl.DataClass
{
    public class TurbulenceEffectData : EffectData
    {
        #region 属性
        private Vector2 _effectSize=new Vector2(512f,512f);
        /// <summary>
        /// 获取或设置效果图像大小
        /// </summary>
        public Vector2 EffectSize
        {
            get { return _effectSize; }
            set
            {
                _effectSize = value;
                OnPropertyChanged();
                SetIsChanges();
            }
        }

        private Vector2 _offset = new Vector2(0, 0);

        /// <summary>
        /// 效果偏移属性
        /// </summary>
        public Vector2 Offset
        {
            get { return _offset; }
            set
            {
                _offset = value; OnPropertyChanged();
                SetIsChanges();
            }
        }

        private Vector2 _frequency=new Vector2(0.01f,0.01f);
        public Vector2 Frequency
        {
            get { return _frequency; }
            set
            {
                _frequency = value;OnPropertyChanged();SetIsChanges();
            }
        }


        private int _octaves = 1;
        /// <summary>
        /// 八度....
        /// </summary>
        public int Octaves
        {
            get { return _octaves; }
            set
            {
                if (value < 1)
                {
                    _octaves = 1;
                }
                else if (value > 15)
                {
                    _octaves =15;
                }
                else
                {
                    _octaves = value;

                }
                OnPropertyChanged();
                SetIsChanges();
            }
        }

        private int _seed=0;
        /// <summary>
        /// 种子
        /// </summary>
        public int Seed
        {
            get { return _seed; }
            set { _seed = value; OnPropertyChanged(); SetIsChanges(); }
        }

        private bool _tileable;
        /// <summary>
        /// 平铺
        /// </summary>
        public bool Tileable
        {
            get { return _tileable; }
            set { _tileable = value; OnPropertyChanged(); SetIsChanges(); }
        }

        private TurbulenceEffectNoise _noise;
        /// <summary>
        /// 噪声
        /// </summary>
        public TurbulenceEffectNoise Noise
        {
            get { return _noise; }
            set { _noise = value; OnPropertyChanged(); SetIsChanges(); }
        }
        #endregion

        public override  ICanvasImage GetEffect(CanvasDevice device, bool compression )
        {
           
            TurbulenceEffect turbulenceEffect = new TurbulenceEffect()
            {
                Tileable = Tileable,
                Size = EffectSize,
                Noise = Noise,
                Octaves = Octaves,
                Offset = Offset,
                Seed = Seed,
                Frequency = Frequency,

            };
            Size = EffectSize.ToSize();

            return turbulenceEffect;
        }
    }
}
